package main

import (
	"log"
	"sync"
	"time"
)

var wg sync.WaitGroup

func main() {
	ch1 := make(chan int, 3)
	ch1 <- 2
	ch1 <- 1
	ch1 <- 3
	elem1 := <-ch1
	log.Printf("one: %v", elem1)

	wg.Add(1)
	go test("a")

	wg.Add(1)
	go test("b")

	wg.Wait()
}

func test(name string) {
	for i := 0; i < 10; i++ {
		time.Sleep(time.Millisecond * 100)
		log.Printf("test %v - %d", name, i)
	}
	wg.Done()
}
